const Koa = require('koa')
const app = new Koa()

// next调用会直接调用下一个中间件，如果写了next()一定会执行，思想类似于递归
// const one = (ctx, next) => {
//   console.log(1);
//   next() 
//   console.log(2);
// }
// const two = (ctx, next) => {
//   console.log(3);
//   next()
//   console.log(4);
// }
// const three = (ctx, next) => {
//   console.log(5);
//   next()
//   console.log(6);
// }


// 如果中间件没有next，则只会执行当前的中间件，后面的不执行
const one = (ctx, next) => {
  console.log(1);
  // next() 
  console.log(2);
}
const two = (ctx, next) => {
  console.log(3);
  // next()
  console.log(4);
}
const three = (ctx, next) => {
  console.log(5);
  // next()
  console.log(6);
}


app.use(one)
app.use(two)
app.use(three)

app.listen(3000)